<?
include "../conf/db_connect.php";
if(!$login->logged_in && $_SESSION['date']['isAdmin'] != 1){
	header("Location: ".$CS."admin/");
}

if(sizeof($_POST)){
	mysql_query("update pagini set continut = '".$_POST['continut']."' where id = '{$_GET['page_id']}'");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/adminul.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Diete 4U  - Admin Area</title>
<!-- InstanceEndEditable -->
<link href="../style_admin.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {font-size: 18px}
.style2 {color: #FFFFFF}
-->
</style>
<script src="../js.js.php"></script>
<!-- InstanceBeginEditable name="head" -->
<script src="../ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="../ckfinder/ckfinder.js"></script>
<script>
window.onload = function(){
	var ed1 = CKEDITOR.replace('continut');
	CKFinder.SetupCKEditor( ed1,'../ckfinder/') ;
}
</script>
<!-- InstanceEndEditable -->
<link href="../style_admin.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td height="70" background="images/bg_sus.jpg"><img src="../logo_mic.jpg" width="141" height="59" align="absmiddle" /><span class="style1">Zona de administrare </span>
      <?
	if($login->logged_in && $_SESSION['date']['isAdmin'] == 1){
	?>
	  <div style="position:absolute; width:250px; text-align:right; height:25px; right:0; top:0; background-color:#333333; color:#FFFFFF; padding-right:20px; padding-top:4px;">
	Welcome <?=$_SESSION['date']['nume']." ".$_SESSION['date']['prenume']?>! | <a style="color:#00FFFF" href="<?=$CS?>admin/logout.php">Logout</a>
	</div>
	<?
	}
	?>
	</td>
  </tr>
  <?
  if($login->logged_in && $_SESSION['date']['isAdmin'] == 1){
  ?>
  <tr>
    <td><table width="100%" border="0" cellpadding="4" cellspacing="2">
      <tr>
        <td align="center" bgcolor="#333333"><a href="<?=$CS?>"><strong>Home</strong></a></td>
        <td align="center" bgcolor="#333333"><a href="articole.php"><strong>Articole</strong></a></td>
        <td align="center" bgcolor="#333333"><a href="categorii.php"><strong>Categorii</strong></a></td>
        <td align="center" bgcolor="#333333"><a href="pagini.php"><strong>Pagini statice </strong></a></td>
        <td align="center" bgcolor="#333333"><a href="membri.php"><strong>Membri</strong></a></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td><div align="left" style="padding:15px;"><!-- InstanceBeginEditable name="Centru" -->
      <h1>Pagini statice</h1>
      <p>
        <?
	if(!isset($_GET['page_id'])){
	?>
      </p>
      <form id="form2" name="form2" method="get" action="pagini.php">
        <div align="center">
          <select name="page_id" id="page_id">
            <?
		  $sql = "select * from pagini order by nume";
		  $res = mysql_query($sql);
		  while($p = mysql_fetch_array($res)){
		  ?>
            <option value="<?=$p['id']?>" selected="selected">
              <?=$p['nume']?>
              </option>
            <?
		  }
		  ?>
          </select>
          &nbsp;&nbsp;
          <input name="Submit2" type="submit" class="buton" value="Editeaza" />
        </div>
      </form>
      <?
	  }else{
	  $page = mysql_fetch_array(mysql_query("select * from pagini where id = '{$_GET['page_id']}'"));
	  ?>
      <p align="center"><strong>Editeaza pagina &quot;
        <?=$page['nume']?>
  &quot;</strong></p>
      <p align="center"><a href="pages.php">Inapoi la selectarea paginii</a></p>
      <form action="pagini.php?page_id=<?=$_GET['page_id']?>" method="post" name="paginile" id="paginile">
        <p><strong>Continut</strong></p>
        <p>
          <textarea name="continut" cols="80" rows="7" id="continut"><?=$page['continut']?>
      </textarea>
        </p>
        <p>&nbsp;</p>
        <p>
          <input name="button" type="submit" class="buton" id="button" value="Salveaza" />
        </p>
      </form>
      <?
	  }
	  ?>
    <!-- InstanceEndEditable --></div></td>
  </tr>
  <?
  }else{
  ?>
  <tr>
    <td><div align="left" style="padding:15px;">
	<?
	if(isset($_POST['login']) && $_SESSION['date']['isAdmin'] != 1){
	$login->logout();
	?>
	<div class="mesaj_not_ok" align="center">Bad email and password. </div>
	<?
	}
	?>
      <form id="form1" name="form1" method="post" action="<?=$CS?>admin/">
        <p>Please login if you want to access this section.</p>
        <p><strong>User:</strong></p>
        <p>
          <input name="username" type="text" id="username" /> 
            <input name="login" type="hidden" id="login" value="asdasdas" />
        </p>
        <p><strong>Parola:</strong></p>
        <p>
          <input name="password" type="password" id="password" />
        </p>
        <p>
          <input name="Submit" type="submit" class="buton" value="Login" />
        </p>
      </form>
      </div></td>
  </tr>
  <?
  }
  ?>
  <tr>
    <td height="30" align="center" bgcolor="#333333"><span class="style2">Copyright &copy; 2009 Diete4u.com </span></td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>
